<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>修改密码</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/swiper.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/layer.css" />
    <link rel="stylesheet" type="text/css" href="../css/mdw.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/swiper.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/layer.js"></script>
    <script type="text/javascript" src="../script/mdw.js"></script>
    <script type="text/javascript" src="../script/jumpPage.js"></script>
</head>
<body>
    <header class="header loginHeader">
        <div class="backPrevPage" onclick="historyBack()"></div>
        <div class="pageTitle">修改密码</div>
    </header>
    <section class="loginBox HTML_BOX">
        <div class="bg-eee" style="border-bottom:.2rem solid #EEE ; "></div>
        
        <ul class="registerForm forget plr">
            <li class="">
                <span>手机号/邮箱</span>
                <input id="phone" placeholder="请输入手机号或邮箱"  />
            </li>
            <li class="yzm">
                <span>验证码</span>
                <input id="yzm" placeholder="请输入验证码"  />
                <div onclick="hqyzmCn()" class="hq_yzm">获取验证码</div>
            </li>
            <li class="">
                <span>原密码</span>
                <input type="password" placeholder="请输入原密码"  />
            </li>
            <li class="">
                <span>新密码</span>
                <input type="password" placeholder="请输入新密码"  />
            </li>
            <li class="">
                <span>确认密码</span>
                <input type="password" placeholder="情再次输入密码"  />
            </li>
        </ul>
       
        <div class="loginBtn f_c">确定</div>
       
    </section>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
    $(".loginBtn").click(function(){
        var layers = "";
        var isnull = false;
        $(".forget input").each(function(i,item){
            var val = $(item).val();
            if(val == "" && !isnull){
                switch(i){
                    case 0:
                    layers = "请输入手机号或邮箱";
                    if(cnen==2){
                        layers = 'Please enter your cell phone number or Email';
                    }
                    isnull = true;
                    break;
                    case 1:
                    layers = "请输入验证码";
                    if(cnen==2){
                        layers = 'Please enter the validation code';
                    }
                    isnull = true;
                    break;
                    case 2:
                    layers = "请输入原密码";
                    if(cnen==2){
                        layers = 'Please input a old password';
                    }
                    isnull = true;
                    break;
                    case 3:
                    layers = "请输入新密码";
                    if(cnen==2){
                        layers = 'Please input a new password';
                    }
                    isnull = true;
                    break;
                    case 4:
                    layers = "情再次输入密码";
                    if(cnen==2){
                        layers = 'Please make sure the password is correct';
                    }
                    isnull = true;
                    break;
                }
            }
        });
        if(isnull){
            console.log(layers);
            pop.notice(layers);
            return;
        }
        var v = regPhoneOrEmail($("#phone").val());
        if(v!=""){
        	pop.notice(v);
        	return;
        }
        if($("#password").val() != $("#repassword").val()){
        	pop.notice("两次密码不一致");
            return;
        }
        var p ={type:'change',number:$("#phone").val(),verify:$("#yzm").val(),password:$(".forget input").eq(3).val(),repassword:$(".forget input").eq(4).val(),oldpassword:$(".forget input").eq(2).val()}
            getAjax(Interface.forget_pass,p,function(res){
               pop.notice("修改成功",2,function(){
                    historyBack();
               }); 
        },function(res,err){})
    });

    function hqyzmCn(){
        var html = $(".hq_yzm").html();
        var phone = $("#phone").val();
        var v = regPhoneOrEmail(phone);
        if(html =="获取验证码"){
            if(v!=""){
                pop.notice(v);
                return;
            }
            var p ={number:phone,type:2};
            console.log(JSON.stringify(user));
            pop.loading();
            getAjax(Interface.send_verify,p,function(res){
                pop.close();
                pop.notice("短信验证码已发送");
                $(".hq_yzm").addClass("on");
                $(".hq_yzm").html(yzmtime + "秒后重试");
                zym = setInterval(yzmsetInterval,1000);
            },function(res,err){})

        }
    }

    function hqyzmEn(){
        var html = $(".hq_yzm").html();
        var phone = $("#phone").val();
        var v = regPhoneOrEmail(phone);
        if(html =="Send Code"){
            if(v!=""){
                pop.notice(v);
                return;
            }
            if(gj==""||gj ==null){
                pop.notice('Please choose the country');
            }
            var p ={number:phone,type:2};
            pop.loading();
            getAjax(Interface.send_verify,p,function(res){
                pop.close();
                pop.notice("SMS has been sent");
                $(".hq_yzm").addClass("on");
                $(".hq_yzm").html(yzmtime + "s retry");
                zym = setInterval(yzmsetInterval,1000);
            },function(res,err){})

        }
    }


    apiready = function(){
        $api.fixStatusBar($api.dom('header'));
        api.setStatusBarStyle({
            color: '#fff',//设置APP状态栏背景色
            style: 'dark'
        });
        ifCnAndEn();
    };
</script>
<script type="text/javascript">
    function ifCnAndEn(){
        var html = '';
        if(cnen==2){
            $(".pageTitle").html('Password');
            
            $(".registerForm li").eq(0).find('span').html('Phone/Email');
            $(".registerForm li").eq(1).find('span').html('Security Code');
            $(".registerForm li").eq(2).find('span').html('Password');
            $(".registerForm li").eq(3).find('span').html('New Password');
            $(".registerForm li").eq(4).find('span').html('Confirm Password');
            $(".registerForm li").eq(0).find('input').attr('placeholder','');
            $(".registerForm li").eq(1).find('input').attr('placeholder','');
            $(".registerForm li").eq(2).find('input').attr('placeholder','');
            $(".registerForm li").eq(3).find('input').attr('placeholder','');
            $(".registerForm li").eq(4).find('input').attr('placeholder','');

            $(".loginBtn").html('Save');
            $(".hq_yzm").html('Send Code');
            $(".hq_yzm").attr("onclick",'hqyzmEn()');
        }
    }
</script>
</html>